package com.example.qxfw.cshx.controller;

import com.example.qxfw.common.SysResult;
import com.example.qxfw.common.entity.zy.CcshxImpDot;
import com.example.qxfw.cshx.service.CshxZymbService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

@ApiIgnore
@Api(tags = "城市火险--重要目标")
@RestController
@CrossOrigin
@RequestMapping("/ImportantGoalController")
public class ImportantGoalController {
    @Autowired
    private CshxZymbService zymbService;

    @ApiOperation("城市火险--重要目标-查询")
    @GetMapping("/getAllCcshxImpDot")
    public SysResult getAllCcshxImpDot(){
        List<CcshxImpDot> list = zymbService.getAllCcshxImpDot();
        return SysResult.success(list);
    }

    @ApiOperation("城市火险--重要目标-添加")
    @RequestMapping("/insertOneData")
    public SysResult insertOneData(@RequestBody CcshxImpDot ccshxImpDot){
        CcshxImpDot info = zymbService.insertOneData(ccshxImpDot);
        if (info != null){
            return SysResult.success(info);
        }else {
            return SysResult.fail("添加失败！！！");
        }
    }

    @ApiOperation("城市火险--重要目标-修改")
    @PutMapping("/updateById")
    public SysResult updateById(@RequestBody CcshxImpDot ccshxImpDot){
        CcshxImpDot info = zymbService.updateById(ccshxImpDot);
        if (info != null){
            return SysResult.success(info);
        }else {
            return SysResult.fail("更新失败！！！");
        }
    }

    @ApiOperation("城市火险--重要目标-删除")
    @RequestMapping("/deleteById")
    public SysResult deleteById(int id){
        int i = zymbService.deleteById(id);
        return SysResult.success(i);
    }

    @ApiOperation("城市火险--重要目标-关联站点")
    @RequestMapping("/getAllStationName")
    public SysResult getAllStationName(){
        List<CcshxImpDot> list = zymbService.getAllStationName();
        return SysResult.success(list);
    }

}
